package com.gxa.retail_admin.controller;

import com.gxa.common.vo.Q;
import com.gxa.common.vo.ResultVo;
import com.gxa.modules.pojo.*;
import com.gxa.modules.service.LsFinanceService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: zdk
 * Date: 2021/12/27 19:58
 * Description:
 * Version: V1.0
 */
@Controller
@Api(value = "财务管理",tags = "财务管理接口API（李帅）")
@RequestMapping("/staging/finance")
public class LsFinanceController {

    @Autowired(required = false)
    LsFinanceService lsFinanceService;

    @RequestMapping(value = "/addForders", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "新增财务订单信息", notes = "新增财务订单信息", httpMethod = "POST", response = String.class)
    @RequiresPermissions("财务中心")
    public ResultVo addForders(@RequestBody @ApiParam(name = "addForders", value = "新增财务订单信息") Forders forders) {
        return lsFinanceService.addForders(forders);
    }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              @RequestMapping(value = "/addFinanceUser", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "新增财务用户信息", notes = "新增财务用户信息", httpMethod = "POST", response = String.class)
    @RequiresPermissions("财务中心")
    public ResultVo addFinanceUser(@RequestBody @ApiParam(name = "Finance_User", value = "新增财务用户信息") Finance_User financeUser) {
        return lsFinanceService.addFinanceUser(financeUser);
    }

    @RequestMapping(value = "/addFinancePayment", method = RequestMethod.GET)
    @ApiOperation(value = "新增员工工资发放情况", notes = "员工工资发放情况", httpMethod = "GET", response = String.class)
    @ApiImplicitParam(name = "todayDate",value = "今日时间",paramType = "query",dataType = "String",required = true)
    @ResponseBody
    @RequiresPermissions("财务中心")
    public ResultVo addFinancePayment(@RequestParam(name = "todayDate") Date todayDate) {
        return lsFinanceService.addFinancePayment(todayDate);
    }

    @RequestMapping(value = "/addFinanceAdjustment", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "新增员工工资调整信息", notes = "新增员工工资调整信息", httpMethod = "POST", response = String.class)
    @RequiresPermissions("财务中心")
    public ResultVo addFinanceAdjustment(@RequestBody @ApiParam(name = "Finance_Adjustment", value = "员工工资调整") Finance_Adjustment financeAdjustment) {
        return lsFinanceService.addFinanceAdjustment(financeAdjustment);
    }

    @RequestMapping(value = "/queryFinanceToday",method = RequestMethod.GET)
    @ApiOperation(value = "今日财务总览",notes = "今日财务总览",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "limitPage",value = "显示条数",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "startDate",value = "开始日期",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "endDate",value = "结束日期",paramType = "query",dataType = "String",required = false)
    })
    @ResponseBody
    @RequiresPermissions("财务中心")
    public Q queryFinanceToday(@RequestParam(name = "currentPage")Integer currentPage,
                               @RequestParam(name = "limitPage") Integer limitPage,
                                   @RequestParam(name = "startDate",defaultValue = "1001-01-01")Date startDate,
                                   @RequestParam(name = "endDate",defaultValue = "1001-01-01") Date endDate){
        lsFinanceService.queryFinanceToday(currentPage,limitPage,startDate,endDate);
     Map finance = new HashMap<String,String>();
     finance.put("编号","1");
     finance.put("姓名","张三丰");
     finance.put("用户身份","会员");
     finance.put("消费方式","微信支付");
     finance.put("消费途径","线下");
     finance.put("消费金额","500.02");
     Q q=new Q();
     q.setCode(200);
     q.setMsg("操作成功");
     q.setCount(25);
     q.setData(finance);
     return q;
    }

    @RequestMapping(value = "/queryFinanceYesterday",method = RequestMethod.GET)
    @ApiOperation(value = "昨日财务总览",notes = "昨日财务总览",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "limitPage",value = "显示条数",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "startDate",value = "开始日期",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "endDate",value = "结束日期",paramType = "query",dataType = "String",required = false)
    })
    @ResponseBody
    @RequiresPermissions("财务中心")
    public Q queryFinanceYesterday(@RequestParam(name = "currentPage")Integer currentPage,
                                   @RequestParam(name = "limitPage") Integer limitPage,
                                   @RequestParam(name = "startDate",defaultValue = "1001-01-01")Date startDate,
                                   @RequestParam(name = "endDate",defaultValue = "1001-01-01") Date endDate){
        return queryFinanceToday(currentPage,limitPage,startDate,endDate);
    }

    @RequestMapping(value = "/queryFinanceWeek",method = RequestMethod.GET)
    @ApiOperation(value = "本周财务总览",notes = "本周财务总览",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "limitPage",value = "显示条数",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "startDate",value = "开始日期",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "endDate",value = "结束日期",paramType = "query",dataType = "String",required = false)
    })
    @ResponseBody
    @RequiresPermissions("财务中心")
    public Q queryFinanceWeek(@RequestParam(name = "currentPage")Integer currentPage,
                              @RequestParam(name = "limitPage") Integer limitPage,
                                  @RequestParam(name = "startDate",defaultValue = "1001-01-01")Date startDate,
                                  @RequestParam(name = "endDate",defaultValue = "1001-01-01") Date endDate){
        return queryFinanceToday(currentPage,limitPage,startDate,endDate);
    }

    @RequestMapping(value = "/queryFinanceMonth",method = RequestMethod.GET)
    @ApiOperation(value = "本月财务总览",notes = "本月财务总览",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "limitPage",value = "显示条数",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "startDate",value = "开始日期",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "endDate",value = "结束日期",paramType = "query",dataType = "String",required = false)
    })
    @ResponseBody
    @RequiresPermissions("财务中心")
    public Q queryFinanceMonth(@RequestParam(name = "currentPage")Integer currentPage,
                               @RequestParam(name = "limitPage") Integer limitPage,
                                   @RequestParam(name = "startDate",defaultValue = "1001-01-01")Date startDate,
                                   @RequestParam(name = "endDate",defaultValue = "1001-01-01") Date endDate){
        return queryFinanceToday(currentPage,limitPage,startDate,endDate);
    }

    @RequestMapping(value = "/queryFinanceDaily",method = RequestMethod.GET)
    @ApiOperation(value = "每日对账",notes = "每日对账",httpMethod = "GET", response = String.class)
    @ApiImplicitParam(name = "shopId",value = "门店编号",paramType = "query",dataType = "String",required = true)
    @ResponseBody
    @RequiresPermissions("财务中心")
    public ResultVo queryFinanceDaily(@RequestParam(name = "shopId")Integer shopId){
        return lsFinanceService.queryFinanceDaily(shopId);
    }

    @RequestMapping(value = "/queryFinanceEmployee",method = RequestMethod.GET)
    @ApiOperation(value = "员工查询",notes = "员工查询",httpMethod = "GET", response = String.class)
    @ApiImplicitParam(name = "shopId",value = "门店编号",paramType = "query",dataType = "String",required = true)
    @ResponseBody
    @RequiresPermissions("财务中心")
    public ResultVo queryFinanceEmployee(@RequestParam(name = "shopId")Integer shopId){
        return lsFinanceService.queryFinanceEmployee(shopId);
    }

    @RequestMapping(value = "/queryFinancePaymentList",method = RequestMethod.POST)
    @ApiOperation(value = "日结记录接口",notes = "日结记录接口",httpMethod = "POST", response = String.class)
    @ResponseBody
    @RequiresPermissions("财务中心")
    public Q queryFinancePaymentList(@RequestBody @ApiParam(name = "QueryFinancePayment", value = "日结记录查询")QueryFinancePayment queryFinancePayment){
        return lsFinanceService.queryFinancePaymentList(queryFinancePayment);
    }

    @RequestMapping(value = "/queryFinancePaymentListSearch",method = RequestMethod.GET)
    @ApiOperation(value = "日结记录搜索接口",notes = "日结记录搜索接口",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "search",value = "搜索条件",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "limitPage",value = "显示条数",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "shopId",value = "门店id",paramType = "query",dataType = "String",required = true)
    })
    @ResponseBody
    @RequiresPermissions("财务中心")
    public Q queryFinancePaymentListSearch(@RequestParam(name = "search")String search,
                                           @RequestParam(name = "currentPage")Integer currentPage,
                                           @RequestParam(name = "limitPage")Integer limitPage,
                                           @RequestParam(name = "shopId")Integer shopId){
        return lsFinanceService.queryFinancePaymentListSearch(search,currentPage,limitPage,shopId);
    }


}
